<?php
function reequipment_adminapi_updateequipment($args)
{
    // Get arguments from argument array
    extract($args);

    // Get datbase setup
    $dbconn =& xarDBGetConn();
    $xartable =& xarDBGetTables();
    $table = $xartable['reequipment'];

    $update = array();
    $bindvars = array();

    // Update item
    $query = "UPDATE $table SET ";
    if (isset($equipment_id)){
        $update[] = "equipment_id = ? ";
        $bindvars[] = $equipment_id;
    }
    if (isset($area_id)){
        $update[] = "area_id = ? ";
        $bindvars[] = $area_id;
    }
    if (isset($model_id)){
        $update[] = "model_id = ? ";
        $bindvars[] = $model_id;
    }
    if (isset($company_id)){
        $update[] = "company_id = ? ";
        $bindvars[] = $company_id;
    }
    if (isset($serial_number)){
        $update[] = "serial_number = ? ";
        $bindvars[] = $serial_number;
    }    
    if (isset($machine_name)){
        $update[] = "machine_name = ? ";
        $bindvars[] = $machine_name;
    }    
    if (isset($voltage)){
        $update[] = "voltage = ? ";
        $bindvars[] = $voltage;
    }   
    if (isset($cycles)){
        $update[] = "cycles = ? ";
        $bindvars[] = $cycles;
    }       
    if (isset($inactive)){
        $update[] = "inactive = true ";
    }       
    $query .= join(",",$update);
    $query .= "WHERE equipment_id = ? ";
    $bindvars[] = $equipment_id;
    $result =& $dbconn->Execute($query, $bindvars);
    if (!$result) return;
    // Let any hooks know that we have created a new topic
    $args['module'] = 'reequipment';
    $args['itemtype'] = 4; //tag
    $args['itemid'] = $equipment_id;
    xarModCallHooks('item', 'update', $equipment_id, $args);
    // Return the id of the newly created link to the calling process
    return true;
}
?>